//
//  HomeViewController.m
//  DevIPad
//
//  Created by HuCongshi on 15/11/14.
//  Copyright © 2015年 HuCongshi. All rights reserved.
//

#import "HomeViewController.h"
#import "macro.h"
@interface HomeViewController ()

@property (nonatomic, strong) UITextView *alertInfoView;
@property (nonatomic, strong) UITextView *systemInfoView;
@property (nonatomic, strong) UITextView *resourceInfoView;
@property (nonatomic, strong) UITextView *orderInfoView;

@end

@implementation HomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initItems];
    [self refreshInfo];
    // Do any additional setup after loading the view.
}
- (void)initItems{
    CGRect rx = [UIScreen mainScreen].bounds;
    UIView *banner = [[UIView alloc] initWithFrame:CGRectMake(0, 0, rx.size.width, 100)];
    banner.backgroundColor = [UIColor blueColor];
    [self.view addSubview:banner];
    
    UIView *scanView = [[UIView alloc] initWithFrame:CGRectMake(rx.size.width - 200, 10, 200, 100)];
    //scanView.backgroundColor = [UIColor orangeColor];
    [self.view addSubview:scanView];
    UILabel *scanText = [[UILabel alloc] initWithFrame:CGRectMake(70, 0, 100, 80)];
    scanText.text = @"扫一扫";
    scanText.textColor = [UIColor whiteColor];
    scanText.font = [UIFont systemFontOfSize:28];
    [scanView addSubview:scanText];
    
    UIImageView *scanImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 20, 40, 40)];
    scanImageView.image = [UIImage imageNamed:@"scan.png"];
    [scanView addSubview:scanImageView];
    
    UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapScan:)];
    [scanView addGestureRecognizer:gesture];
    
    
    UIView *hLine = [[UIView alloc] initWithFrame:CGRectMake(rx.size.width/2.0-1, 100, 2, rx.size.height-200)];
    hLine.backgroundColor = [UIColor blueColor];
    [self.view addSubview:hLine];
    
    UIView *vLine = [[UIView alloc] initWithFrame:CGRectMake(0, rx.size.height/2.0-1, rx.size.width, 2)];
    vLine.backgroundColor = [UIColor blueColor];
    [self.view addSubview:vLine];
    
    UILabel *warningLabel = [[UILabel alloc] initWithFrame:CGRectMake(rx.size.width/4.0-50, 110, 100, 30)];
    warningLabel.text = @"告警";
    warningLabel.textAlignment = NSTextAlignmentCenter;
    warningLabel.textColor = [UIColor blackColor];
    warningLabel.font = [UIFont systemFontOfSize:24];
    [self.view addSubview:warningLabel];
    
    UILabel *systemLabel = [[UILabel alloc] initWithFrame:CGRectMake(rx.size.width/4.0*3.0-50, 110, 100, 30)];
    systemLabel.text = @"系统信息";
    systemLabel.textAlignment = NSTextAlignmentCenter;
    systemLabel.textColor = [UIColor blackColor];
    systemLabel.font = [UIFont systemFontOfSize:24];
    [self.view addSubview:systemLabel];
    
    UILabel *resourceLabel = [[UILabel alloc] initWithFrame:CGRectMake(rx.size.width/4.0-50, rx.size.height/2.0+10, 100, 30)];
    resourceLabel.text = @"资源";
    resourceLabel.textAlignment = NSTextAlignmentCenter;
    resourceLabel.textColor = [UIColor blackColor];
    resourceLabel.font = [UIFont systemFontOfSize:24];
    [self.view addSubview:resourceLabel];
    
    UILabel *orderLabel = [[UILabel alloc] initWithFrame:CGRectMake(rx.size.width/4.0*3.0-50, rx.size.height/2.0+10, 100, 30)];
    orderLabel.text = @"工单";
    orderLabel.textAlignment = NSTextAlignmentCenter;
    orderLabel.textColor = [UIColor blackColor];
    orderLabel.font = [UIFont systemFontOfSize:24];
    [self.view addSubview:orderLabel];
    
    self.alertInfoView = [[UITextView alloc] initWithFrame:CGRectMake(40, 145, rx.size.width/2-60, rx.size.height/2-160)];
    //self.alertInfoView.backgroundColor = [UIColor orangeColor];
    self.alertInfoView.font = [UIFont systemFontOfSize:20];
    self.alertInfoView.editable = NO;
    self.alertInfoView.scrollEnabled = YES;
    self.alertInfoView.textAlignment = NSTextAlignmentLeft;
    [self.view addSubview:self.alertInfoView];
    
    self.systemInfoView = [[UITextView alloc] initWithFrame:CGRectMake(40+rx.size.width/2.0, 145, rx.size.width/2-60, rx.size.height/2-160)];
    //self.systemInfoView.backgroundColor = [UIColor orangeColor];
    self.systemInfoView.font = [UIFont systemFontOfSize:20];
    self.systemInfoView.editable = NO;
    self.systemInfoView.scrollEnabled = YES;
    self.systemInfoView.textAlignment = NSTextAlignmentLeft;
    [self.view addSubview:self.systemInfoView];
    
    self.resourceInfoView = [[UITextView alloc] initWithFrame:CGRectMake(40, rx.size.height/2.0+45, rx.size.width/2-60, rx.size.height/2-160)];
    //self.resourceInfoView.backgroundColor = [UIColor orangeColor];
    self.resourceInfoView.font = [UIFont systemFontOfSize:20];
    self.resourceInfoView.editable = NO;
    self.resourceInfoView.scrollEnabled = YES;
    self.resourceInfoView.textAlignment = NSTextAlignmentLeft;
    [self.view addSubview:self.resourceInfoView];
    
    self.orderInfoView = [[UITextView alloc] initWithFrame:CGRectMake(40+rx.size.width/2.0, rx.size.height/2.0+45, rx.size.width/2-60, rx.size.height/2-160)];
    //self.orderInfoView.backgroundColor = [UIColor orangeColor];
    self.orderInfoView.font = [UIFont systemFontOfSize:20];
    self.orderInfoView.editable = NO;
    self.orderInfoView.scrollEnabled = YES;
    self.orderInfoView.textAlignment = NSTextAlignmentLeft;
    [self.view addSubview:self.orderInfoView];
}
-(void)refreshInfo{
    self.alertInfoView.text = @"告警信息:\n告警：XXX，时间：XXX，故障XXX\n告警：XXX，时间：XXX，故障XXX\n告警：XXX，时间：XXX，故障XXX\n告警：XXX，时间：XXX，故障XXX";
    self.systemInfoView.text = @"告警信息:\n告警：XXX，时间：XXX，故障XXX\n告警：XXX，时间：XXX，故障XXX\n告警：XXX，时间：XXX，故障XXX\n告警：XXX，时间：XXX，故障XXX";
    self.resourceInfoView.text = @"资源利用情况信息:\n资源：XXX，利用率：XXX\n资源：XXX，利用率：XXX\n资源：XXX，利用率：XXX\n资源：XXX，利用率：XXX";
    self.orderInfoView.text = @"工单信息:\n工单号：XXX，内容：XXX\n工单号：XXX，内容：XXX\n工单号：XXX，内容：XXX\n工单号：XXX，内容：XXX";
}
-(void)tapScan:(UITapGestureRecognizer*)recongizer{
    NSLogINFO(@"Tap");
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
